<template>

  <div id="courseware" @click.capture="closeMessagecenter" style=" border-radius: 12px 0px 0px 0px;">
    <!-- <div class="leftTop"></div> -->
    <mymenu :menuList="menuList" :teachStatus="status" :isInitPage="isInitPage" @initLessonItems="initLessonItems" @initDiyLessonItems="initDiyLessonItems" ref="menus"></mymenu>
    <div class="resource" :class="{ 'resource-lessons': giveLessons }">
      <div :class="['top-title', 'flex-between', { 'top-title-lessons': giveLessons }]">
        <div class="title flex-start">
            <!-- <img class="lesson-logo" src="../../assets/img/home/lesson-logo.png" alt=""> -->
            <span class="s-24 lesson-name">{{ lessonInfo.lessonName }}</span>
            <span v-show="!giveLessons" class="update pointer" v-if="lessonInfo.isRequireUpdate && !lessonInfo.homeDialog" @click="updateLesson">更新</span>
            <span class="downloadAgain" v-if="showdownloadAgain && !isDiyLesson"  @click="downloadAgain">重新下载</span>
        </div>
        <transition name="fade" mode="in-out">
          <div class="switch flex-start" v-show="!giveLessons && !isDiyLesson" :style="showTab ? '' : 'visibility: hidden;'">
            <div class="cursor align-center switch-item" :class="{ isactive: active === 1 }" @click="toSwitch(1)">
              <span class="s-14 pointer">教学资源</span>
            </div>
            <div class="cursor align-center switch-item" v-if="showTeachPlan" :class="{ isactive: active === 2 }" @click="toSwitch(2)">
              <span class="s-14 pointer">{{ eduLevel === 'primary' ? '教学设计' : '学生练习' }}</span>
            </div>
          </div>
        </transition>
        <!-- <transition name="fade" mode="out-in"> -->
        <div v-show="!giveLessons">
            <button  :style="active !== 1 ? 'visibility: hidden' : ''" :class="['pointer', 'flex-center', 'cursor', 'start', 's-14', 'status', `${!isHomeDialogShow ? '' : 'dis-btn'}`,`${isEmptyLesson ? 'dis-btn' : ''}`]" :disabled="isHomeDialogShow || isEmptyLesson" @click="giveLessonHandle">
                上课模式
            </button>
        </div>
        <!-- </transition> -->
        <div v-show="giveLessons">
          <button class="pointer s-14 start status" style="background: #0085ff;" @click="setGiveLessons(false)">备课模式</button>
          <button class="pointer s-14 start status" style="margin-left: 15px;" @click="openTool">开始上课</button>
        </div>

        <!-- <button :style="active!==1 ?'visibility: hidden' :''"
                    :class="['pointer','flex-center', 'cursor', 'start', 's-16','status',`${!isHomeDialogShow?'':'dis-btn'}`]"
                    :disabled="isHomeDialogShow" @click="giveLessonHandle">
                    {{status}}
                </button> -->
      </div>
      <div v-show="!lessonInfo.isResourceEmpty" id="coursewareContainer">
        <lesson ref="lessonRef" v-show="active === 1 " ></lesson>
        <desgin ref="desginRef" v-if="active === 2" :pdfSrc="pdfSrc"></desgin>
      </div>
      <div v-if="lessonInfo.isResourceEmpty">
        <desgin ref="desginRef" v-if="active === 2" :pdfSrc="pdfSrc"></desgin>
        <empty v-show="active === 1" :sqlParams="sqlParams"></empty>
      </div>
      <home-dialog v-if="isHomeDialogShow" :shadeInfo="lessonInfo.shadeInfo" :lessonId="menuList.currentLesson" :bookId="menuList.bookId"></home-dialog>
    </div>
    <beginner-guidance v-if="isShowBeginnerGudiance" :isShowBeginnerGudiance.sync="isShowBeginnerGudiance"> </beginner-guidance>
    <div class="syncDownload" v-if="showsyncDownloadMask">
        <syncDownloadMask></syncDownloadMask>
    </div>
  </div>
</template>

<script>
  import resource from '@/content/api/resource'
  import schoolApi from '../../api/school'
  import userApi from '../../api/user'
  import usermeta from '../../api/usermeta.js'
  import mymenu from './Menu'
  import store from '@/content/store/index.js'
  import lesson from './Lesson'
  import desgin from './desgin'
  import empty from './empty'
  import homeDialog from './home_dialog/Main'
  import syncDownloadMask from './home_dialog/syncDownloadMask'
  import { SqlLib } from '../../../../../static/lib/sqlite/SqlLib'
  import { User } from '../../../../../static/lib/sqlite/model/User'
  import { SqlLibUser } from '../../../../../static/lib/sqlite/service/SqlLibUser'
  import { SqlLibBook } from '../../../../../static/lib/sqlite/service/SqlLibBook'
  import { Book } from '../../../../../static/lib/sqlite/model/Book'
  import { Publisher } from '../../../../../static/lib/sqlite/model/Publisher'
  import { Chapter } from '../../../../../static/lib/sqlite/model/Chapter'
  import { Lesson } from '../../../../../static/lib/sqlite/model/Lesson'
  import { DownloadCenter } from '../../../../../static/lib/downloader/DownloadCenter'
  import { Downloader } from '../../../../../static/lib/sqlite/model/Downloader'
  import moment from 'moment'
  import { ShowPpt } from '../../utils/ppt'
  import { UpdateApp } from '../../utils/UpdateApp'
  import { VersionUpdater } from '../../../../../static/lib/downloader/VersionUpdater'
  import bus from '../../assets/js/bus'
  import beginnerGuidance from './home_dialog/beginnerGuidance'
  import getMAC from 'getmac'
  import { UUIDUtil } from '../../../../../static/utils/UUIDUtil'
  import { UserClassEvents } from '../../../../../static/lib/sqlite/model/UserClassEvents'
  import { mapMutations, mapState } from 'vuex'
  import { collectUserPoint } from '../../api/point'
  import { FileUtil } from '../../../../../static/utils/FileUtil'
  const cryUtil = require('../../../../../static/utils/CrypUtil')
  export default {
    props: ['messageCenterIsShow'],
    components: { mymenu, lesson, desgin, empty, homeDialog, beginnerGuidance , syncDownloadMask },
    inject: ['initPersonStatus', 'refreshHomePage',],
    provide() {
        return {
            initPage: this.initPage,
            initLessonItems:this.initLessonItems,
            initDiyLessonItems:this.initDiyLessonItems,
            pushOneLessonToCenter: this.pushOneLessonToCenter,
            changeDownloadStatus: this.changeDownloadStatus,
            cancelShadeStatus: this.cancelShadeStatus,
            updateBookAuthorize: this.updateBookAuthorize,
            resetLesson: this.resetLesson,
            resetLessons: this.resetLessons,
            resetInitPage: this.resetInitPage,
            saveAllbook:this.saveAllbook,
        }
    },
    data() {
      return {
        menuList: {
          course: [],
          bookName: '',
          bookId: '',
          isAuthorized: false,
          currentLesson: '',
          userId: '',
        },
        lessonInfo: {
            lessonItems: [],
            lessonName: '',
            isRequireUpdate: false,
            isResourceEmpty: false,
            homeDialog: false,
            isCharged: '',
            shadeInfo: {
                authCode: '1', // 1 - 鉴权页面； 2 - 获取授权码页面
                isDownloading: false,
                downloadStatus: false, //下载按钮的状态标识
            },
        },
        active: 1,
        pdf_pages: [],
        pdfDoc: null,
        currentPage: 0, // pdf文件页码
        pageCount: 0, // pdf文件总页数
        fileType: 'pdf', // 文件类型
        src: '',
        pdfSrc: '',
        status: '授课模式',
        isLoading: false,
        showPptObj: new ShowPpt(),
        isShowBeginnerGudiance: false,
        showsyncDownloadMask:false,
        showTab: false,
        isDiyLesson:false,
        eduLevel: window.eduLevel,
        isInitPage: true,
        // reloadLesson:false,
        teachMode:'',
        isEmptyLesson:false,
        showdownloadAgain:false
      }
    },
    created() {
       
    },
    mounted() {
        bus.$on('refreshHome', () => {
            this.refreshHomePage()
        });
        bus.$on('isshowdownloadAgain',(val)=>{
            this.showdownloadAgain = val
        })
        let _this = this
        bus.$on('syncDownload',(val)=>{
            // console.log('syncDownload-----------------' , val);
            if (!val && window.progressInterval) {
                clearInterval(window.progressInterval);
                console.log('结束进度-------------------------');
            }
            this.showsyncDownloadMask = val
        })
        window.addEventListener('changeDownloadStatus', function (event) {
        console.log('Courseware.vue changeDownloadStatus event touch')
        if (event.detail && event.detail.lessonId) {
          if (event.detail.actionStatus && (event.detail.actionStatus === '1' || event.detail.actionStatus === '0')) {
            //代表是更新
            if (event.detail.lessonId === _this.menuList.currentLesson) {
              _this.lessonInfo.isRequireUpdate = false
            }
            _this.menuList.course.forEach((course) => {
              course.lessonVOList.forEach((tLesson) => {
                if (tLesson.id === event.detail.lessonId) {
                  tLesson.isUpdate = false
                }
              })
            })
          }
          _this.cancelShadeStatus(event.detail.lessonId)
        }
      })
      this.$nextTick(() => {
        _this.initPage()
      })
      this.$electron.ipcRenderer.on('changeStatus', () => {
        if (this.showPptObj) {
          this.showPptObj.shutDownPpt()
        }
        this.status = '授课模式'
      })
      let sqlLib = SqlLib.getInstance(window.$DBDIR)
      let user = SqlLibUser.queryCurrentUser(sqlLib)
      if (user) {
        this.showTab = user.eduLevelId !== this.$CONST.global.eduLevel.high
      }
      //接受课程进度消息
      const tMessage = new BroadcastChannel('t-progess-message')
      tMessage.addEventListener('message', (e) => {
        console.log(e)
        const { bookId, lessonId } = e.data
        if (bookId !== this.menuList.bookId) {
          user.bookId = bookId
          user.lessonId = lessonId
          sqlLib.updateObjectById(user)
          this.initPage(bookId, lessonId)
        } else {
          this.menuList.currentLesson = lessonId
        }
        this.$electron.remote.getCurrentWindow().focus()
      })
    },
    activated() {
      let _this = this
      this.$nextTick(() => {
        _this.initPersonStatus()
        let lessonId = _this.$route.params.lessonId
        let bookId = _this.$route.params.bookId

        if (bookId && lessonId) {
          //如果书本和课时id都有则刷新整个页面
          console.log('刷新整个页面');
          _this.refreshHomePage()
        } else {
          if (lessonId) {
            _this.$refs.menus.getLessonItems(lessonId)
          }
        }
      })
    },
    computed: {
        ...mapState(['loadingLessonSet', 'giveLessons']),
        isHomeDialogShow() {
            // console.log('lessonInfo',this.lessonInfo.lessonItems);
            if (this.lessonInfo.lessonItems.length == 0) {
                this.isEmptyLesson = true
            }else{
                this.isEmptyLesson = false
            }
            return this.lessonInfo.homeDialog && this.active === 1
        },
    },
    beforeDestroy() {
        window.removeEventListener('changeDownloadStatus', function (event) {
            console.log('changeDownloadStatus event remove')
        })
    },
    methods: {
      ...mapMutations(['setBookId', 'setUserId', 'setGiveLessons']),
        downloadAgain(){
          bus.$emit('downloadAgain')
        },
        closeMessagecenter() {
            this.$emit('update:messageCenterIsShow', false)
        },
        giveLessonHandle() {
            this.$refs.lessonRef.exitEdit('goclass')
            this.setGiveLessons(true)
        },
      // 打开上课悬浮球
      openTool() {
        console.log('open');
        if (!localStorage.getItem('teachMode')) {
            this.teachMode = 'local'
        }else{
            const key = localStorage.getItem('teachMode')
            switch (key) {
                case '1':
                this.teachMode = 'local'
                    break;
                case '2':
                this.teachMode = 'online'
                break;
                // case '3': 去除智能模式
                //     this.teachMode = localStorage.isOffline == "true" ? 'local' : 'online'
                // break;
                default:
                break;
            }
        }
        console.log(this.teachMode);
        let sqlLib = SqlLib.getInstance(window.$DBDIR)
        let user = SqlLibUser.queryCurrentUser(sqlLib)
        let userResource = SqlLibBook.queryDefaultPpt(sqlLib, this.menuList.currentLesson)
        this.isLoading = true
        setTimeout(() => {
          this.isLoading = false
        }, 500)
        if (this.status === '授课模式') {
            const path = require('path')
            const fs = require('fs')
            if (userResource !== null) {
                if (userResource.resourceType === 'courseware') {
                    if (this.teachMode == 'local'){
                        var respath = path.resolve(window.$DATADIR, 'resc', 'courseware',  userResource.resourceId + '.pptx')
                        if(fs.existsSync(respath)){
                            this.showPptObj.openPpt(respath)
                        }else{
                            this.showPptObj.openPpt(path.resolve(window.$DATADIR, 'resc', 'courseware',  userResource.resourceId + '.ppt'))
                        }
                    }else if(this.teachMode == 'online'){
                        this.$electron.ipcRenderer.send('showResourceHideWindow', { metaId: 'onlinePPT', userId: '',lessonId:userResource.lessonId, onlinePPtId:userResource.resourceId})
                    }
                }
                if (userResource.resourceType === 'selfPpt') {
                    if (this.teachMode == 'local'){
                        let bsr = userResource.resourceDescription
                        let fileName = JSON.parse(bsr).downloadInfo.FileName
                        console.log(user);
                        this.showPptObj.openPpt(path.resolve(window.$DATADIR, 'resc', 'user', 'ppt', user.id, fileName))
                    }else if (this.teachMode == 'online'){
                        if (userResource.reverse3 !== '0') {
                            this.$message.warning('请将本地PPT上传云端后再使用在线模式')
                            return
                        }
                        console.log('在线模式打开自上传PPT',userResource);
                        this.$electron.ipcRenderer.send('showResourceHideWindow', { metaId: 'onlinePPT', userId: '',lessonId:userResource.lessonId, onlinePPtId:userResource.reverse2,pptType:'selfPpt'})
                    } 
                }
            }
            this.$electron.ipcRenderer.send('showSuspensionWindow', { lessonId: this.menuList.currentLesson, userId: user.id })
            let classStartEvent = new UserClassEvents()
            classStartEvent.id = UUIDUtil.uuid()
            classStartEvent.type = '0'
            classStartEvent.createTime = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
            classStartEvent.userId = user.id
            sqlLib.insertObject(classStartEvent)
            
            this.status = '停止授课'
            // this.showPptObj.shutDownPpt();
            collectUserPoint({ channel: 2 })
        } else {
            let classEndEvent = new UserClassEvents()
            classEndEvent.id = UUIDUtil.uuid()
            classEndEvent.type = '1'
            classEndEvent.createTime = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
            classEndEvent.userId = user.id
            SqlLibBook.insertEndClassTime(sqlLib, classEndEvent)
            this.showPptObj.shutDownPpt()
            this.$electron.ipcRenderer.send('hideSuspensionWindow')
            this.status = '授课模式'
        }
      },
      toSwitch(val) {
        if (!this.menuList.isAuthorized && this.lessonInfo.isCharged === '0') {
          this.$message.error('您还未授权本册教材，无法查看教学设计')
          return
        }
        this.active = val
        if (this.active === 2) {
          this.$nextTick(() => {
            this.$refs.desginRef.getDesign(this.menuList.currentLesson, this.lessonInfo.lessonName, this.menuList.bookId)
          })
        }
      },
      showTeachPlan() {
        return localStorage.isOffline && localStorage.isOffline == 'false'
      },
      initPage(bookid, currentLesson,msg) {
        console.log('ischeckDB-----------是否校对本地数据库',msg);
        let _this = this
        let options = {
          title: '正在加载教材',
          time: 5000,
          progress: false,
          full: true,
        }
        let sqlLib = SqlLib.getInstance(window.$DBDIR)
        let user = SqlLibUser.queryCurrentUser(sqlLib)
        var currentBookId = user.bookId
        let tempBook = new Book()
        tempBook.id = bookid || currentBookId
        if (tempBook.id == user.id) {
            let publisher = new Publisher();
                publisher.eduLevelId = '1207900675501076481'
                publisher.name = 'Diy课程'
                publisher.id = user.id
                sqlLib.updateOrInsertObjectById(publisher)
            let book = new Book()
                book.id = user.id
                book.name = '我的课程'
                book.publisherId = user.id
                book.reverse3 = 'userDiy'
                // console.log('book',book);
                sqlLib.updateOrInsertObjectById(book)
            _this.menuList.bookName = '我的课程'
            _this.menuList.bookId = user.id
            _this.setBookId(_this.menuList.bookId)
            if (localStorage.isOffline && localStorage.isOffline == 'false'){
                usermeta.getAllDiyLessons({ //获取我的课程
                    appkey:'NOVO_EDU_BEAUTY_SCIENCE_PC'
                }).then(res=>{
                    console.log('初始化自定义课程',res);
                    _this.menuList.course = []
                    if (res.returnValue.length > 0) {
                        let deleteBook = SqlLibBook.queryChapterLessonByBookId(sqlLib, currentBookId)
                        console.log(deleteBook);
                        if (deleteBook && msg !== 'ischeckDB') {
                            deleteBook.forEach(chapters=>{
                                var isDeleteChapter = true
                                res.returnValue.forEach(item=>{
                                    if (item.subjectId == chapters.id) {
                                        console.log('服务端数据库有这个主题，不需要删');
                                        isDeleteChapter = false
                                        chapters.lessonVO.forEach(dles=>{
                                            var isDeleteLesson = true
                                            item.userDiyLessonVOList.forEach(les=>{
                                                if (dles.id == les.lessonId ) {
                                                    console.log('服务端数据库有这个课程，不需要删');
                                                    isDeleteLesson = false
                                                }
                                            })
                                            if(isDeleteLesson){
                                                console.log(dles.name+'这个课程被删了，本地数据库同步删除');
                                                this.deleteLocalRes(dles.id)
                                                let lesson = new Lesson()
                                                lesson.id = dles.id
                                                sqlLib.deleteObjectById(lesson)
                                            }
                                        })
                                    }
                                })
                                if(isDeleteChapter){
                                    console.log(chapters.name + '这个主题被删了，本地数据库同步删除');
                                    let chapter = new Chapter()
                                    chapter.id = chapters.id
                                    sqlLib.deleteObjectById(chapter)
                                    chapters.lessonVO.forEach(ele=>{
                                        this.deleteLocalRes(ele.id)
                                        let lesson = new Lesson()
                                        lesson.id = ele.id
                                        sqlLib.deleteObjectById(lesson)
                                    })
                                }
                            })
                        }
                        let temp = res.returnValue
                        let tempCs = [] //主题集合
                        let tempLs = [] //课程集合
                        temp.forEach((chapter) => {
                            let tempC = new Chapter()
                            tempC.id = chapter.subjectId + ''
                            tempC.name = chapter.name + ''
                            tempC.bookId = user.id
                            tempC.sortIndex = chapter.sortIndex
                            let lessons = chapter.userDiyLessonVOList
                            let tempLessonVO = []
                            lessons.forEach((lesson) => {
                                let tempL = new Lesson()
                                tempL.id = lesson.lessonId + ''
                                tempL.name = lesson.name
                                tempL.chapterId = tempC.id
                                tempL.isCharged = '1'
                                tempL.sortIndex = lesson.sortIndex
                                tempLs.push(tempL)
                                tempLessonVO.push({
                                    name: tempL.name,
                                    id: tempL.id,
                                    isCharged: tempL.isCharged,
                                    isUpdate: false,
                                })
                            })
                            _this.menuList.course.push({
                                name: tempC.name,
                                id: tempC.id,
                                lessonVOList: tempLessonVO,
                            })
                            tempCs.push(tempC)
                        })
                        this.$store.commit('pushBooks', { id: user.id, timestamp: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') })
                        // let updateBook = SqlLibBook.queryChapterLessonByBookId(sqlLib, currentBookId)
                        sqlLib.updateChapterAndLesson(tempCs, tempLs)
                        this.getBookMessageFromDB(sqlLib, currentBookId)
                    }else{
                        let deleteBook = SqlLibBook.queryChapterLessonByBookId(sqlLib, currentBookId)
                        if (deleteBook) {//A电脑创建过自定义课程，B电脑给删了，再回A电脑此时清空数据库记录
                            deleteBook.forEach(item=>{
                                item.lessonVO.forEach(val=>{
                                    this.deleteLocalRes(val.id)
                                })
                                let chapter = new Chapter()
                                chapter.id = item.id
                                sqlLib.deleteObjectById(chapter)
                            })
                        }
                        console.log('deleteBook',deleteBook);
                        this.lessonInfo.isResourceEmpty = true
                        bus.$emit('emptyDiy')
                    }
                })
                _this.initDownloadCenter()
                _this.menuList.currentLesson = ''
            }else{
                console.log('courseware :: 当前是离线状态！')
                this.getBookMessageFromDB(sqlLib, currentBookId)
            }
        }else{
            let currentBook = sqlLib.selectObjectById(tempBook)
            // console.log(currentBook); //当前课本
            usermeta.createUserBookRecord({
                bookId:user.bookId,
                publisherId:currentBook.publisherId
            })
            _this.menuList.bookName = currentBook.name
            _this.menuList.bookId = currentBook.id
            let curAuth = currentBook.isAuthorize
            curAuth = cryUtil.aesDecrypt(curAuth, tempBook.id, true)
            curAuth = new Buffer(curAuth, 'base64').toString('utf8')
            _this.menuList.isAuthorized = curAuth == '已授权'
            _this.menuList.userId = user.id
            //设置vuex中的booid和userid
            this.setBookId(currentBook.id)
            this.setUserId(user.id)
            if (localStorage.isOffline && localStorage.isOffline == 'false') {
              //在线
              this.collectOsMessage(user.id);//收集系统信息
              this.isInitPage = true
              let loadingMask = _this.$downloadmask('#home', options)
              console.log('courseware :: 当前是在线状态！')
              //初始化下载中心
              _this.initDownloadCenter()
              const params = {
                bookId: currentBookId,
              }
              let hasBeenShowBooks = this.$store.state.hasBeenShowBooks
              let haveOrNo = hasBeenShowBooks.filter((item) => {
                return item.id === currentBookId
              })
              let chapterList = SqlLibBook.queryChapterLessonByBookId(sqlLib, currentBookId)
              const isMessageInit = bookid && currentLesson
              if (!isMessageInit && haveOrNo.length !== 0 && chapterList.length > 0 && currentBook.reverse1 && !isNaN(Date.parse(new Date(currentBook.reverse1))) && Date.now() - new Date(currentBook.reverse1) < 6 * 60 * 60 * 1000) {
                console.log('书本缓存还未到期')
                this.$nextTick(() => {
                  loadingMask.close()
                })
                this.getBookMessageFromDB(sqlLib, currentBookId)
              }
              schoolApi.getChapterLessonByBookId(params)
                  .then((response) => {
                    _this.menuList.course = []
                    if (response.code == '0') {
                      let temp = response.returnValue
                      let tempCs = []
                      let tempLs = []
                      let isneedUpdate = false
                      temp.forEach((chapter) => {
                        let tempC = new Chapter()
                        tempC.id = chapter.id + ''
                        tempC.name = chapter.name + ''
                        // tempC.thumb = chapter.thumb + "";
                        tempC.brief = chapter.brief + ''
                        tempC.bookId = currentBookId
                        tempC.sortIndex = chapter.sortIndex
                        let lessons = chapter.lessonVOList
                        let tempLessonVO = []
                        lessons.forEach((lesson) => {
                          let tempL = new Lesson()
                          tempL.id = lesson.id + ''
                          tempL.name = lesson.name
                          tempL.thumb = lesson.thumb
                          tempL.brief = lesson.brief
                          tempL.resVersion = lesson.resVersion
                          tempL.chapterId = tempC.id
                          tempL.isCharged = lesson.isCharged
                          tempL.sortIndex = lesson.sortIindex
                          let isUpdate = false //默认不需要更新
                          let result = sqlLib.selectObjectById(tempL)
                          if (result == null) {
                            //如果为空，代表没查到
                          } else {
                            //查到的话，需要判断是否更新
                            if (result.resVersion !== lesson.resVersion) {
                              isUpdate = true
                              isneedUpdate = true
                              tempL.resVersion = result.resVersion
                            }
                          }
                          tempLs.push(tempL)
                          tempLessonVO.push({
                            name: tempL.name,
                            id: tempL.id,
                            isCharged: tempL.isCharged,
                            isUpdate: isUpdate,
                          })
                        })
                        _this.menuList.course.push({
                            name: tempC.name,
                            id: tempC.id,
                            lessonVOList: tempLessonVO,
                        })
                        tempCs.push(tempC)
                      })
                    //   bus.$emit('isUpdate',isneedUpdate)
                      this.$store.commit('pushBooks', { id: currentBookId, timestamp: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') })
                      let updateBook = Object.assign(new Book(), currentBook)
                      updateBook.reverse1 = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
                      sqlLib.updateObjectById(updateBook)
                      if (user.lessonId) {
                        //如果存在lessonId
                        let isFindLesson = false
                        for (let i = 0; i < _this.menuList.course.length; i++) {
                          if (!isFindLesson) {
                            for (let j = 0; j < _this.menuList.course[i].lessonVOList.length; j++) {
                              if (_this.menuList.course[i].lessonVOList[j].id === user.lessonId) {
                                isFindLesson = true
                                break
                              }
                            }
                          }
                        }
                        if (isFindLesson) {
                          _this.menuList.currentLesson = currentLesson || user.lessonId
                        } else {
                          _this.menuList.currentLesson = currentLesson || _this.menuList.course[0].lessonVOList[0].id
                        }
                      } else {
                        if (_this.menuList.course.length > 0) {
                          _this.menuList.currentLesson = currentLesson || _this.menuList.course[0].lessonVOList[0].id
                        }
                      }
                      sqlLib.updateChapterAndLesson(tempCs, tempLs)
                    }
                    loadingMask.close()
                  })
                  .catch((error) => {
                    console.log(error)
                    _this.$message.error('网络异常，加载课程失败！')
                    loadingMask.close()
                  })
                }else {
                    //离线
                    console.log('courseware :: 当前是离线状态！')
                    this.getBookMessageFromDB(sqlLib, currentBookId)
                }
            }
      },
        deleteLocalRes(lessonId){
            let sqlLib = SqlLib.getInstance(window.$DBDIR)
            let user = SqlLibUser.queryCurrentUser(sqlLib)
            let lessonResource = SqlLibUser.queryLessonResource(sqlLib, user.id, lessonId)
            //删除自上传资源
            const path = require('path')
            const fs = require('fs')
            lessonResource.forEach(resource=>{//删除用户个人资源文件
                switch (resource.resourceType) {
                   //课件
                    case 'selfPpt':
                        FileUtil.deleteFile(path.resolve(window.$DATADIR, 'resc', 'user', 'ppt', user.id, resource.resourceName))
                        break;
                        //视频
                    case 'selfVideo':
                        let videoPath = path.resolve(window.$DATADIR, 'resc', 'selfVideo',resource.resourceName)
                        if (fs.existsSync(videoPath)) {
                            FileUtil.deleteFile(videoPath)
                        }else{
                            FileUtil.deleteFile(path.resolve(window.$DATADIR, 'resc', 'user', 'video', user.id, resource.resourceName))
                        }
                        break;
                        //图片
                    case 'selfImg':
                        let imgPath = path.resolve(window.$DATADIR, 'resc', 'selfImg',resource.resourceName)
                        console.log(imgPath);
                        if (fs.existsSync(imgPath)) {
                            FileUtil.deleteFile(imgPath)
                        }else{
                            FileUtil.deleteFile(path.resolve(window.$DATADIR, 'resc', 'user', 'img', user.id, resource.resourceName))
                        }
                        break;
                        //pdf文件
                    case 'selfPdf':
                        let pdfPath = path.resolve(window.$DATADIR, 'resc', 'selfPdf',resource.resourceName)
                        if (fs.existsSync(pdfPath)) {
                            FileUtil.deleteFile(pdfPath)
                        }else{
                            FileUtil.deleteFile(path.resolve(window.$DATADIR, 'resc', 'user', 'pdf', user.id, resource.resourceName))
                        }
                        break;
                        //word文件
                    case 'selfWord':
                        let wordPath = path.resolve(window.$DATADIR, 'resc', 'selfWord',resource.resourceName)
                        if (fs.existsSync(wordPath)) {
                            FileUtil.deleteFile(wordPath)
                        }else{
                            FileUtil.deleteFile(path.resolve(window.$DATADIR, 'resc', 'user', 'word', user.id, resource.resourceName))
                        }
                        break;
                        //音频
                    case 'selfAudio':
                        let audioPath = path.resolve(window.$DATADIR, 'resc', 'selfAudio',resource.resourceName)
                        if (fs.existsSync(audioPath)) {
                            FileUtil.deleteFile(audioPath)
                        }else{
                            FileUtil.deleteFile(path.resolve(window.$DATADIR, 'resc', 'user', 'audio', user.id, resource.resourceName))
                        }
                        break;
                    default:
                        break;
                }
            })
            let param = {
                lessonId:lessonId
            }
            //删除本地数据库 用户-课程-资源关系
            SqlLibBook.deleteAllLessonInfoByBookId(sqlLib,param)
        },
      //离线状态改为公用代码段
      getBookMessageFromDB(sqlLib, currentBookId) {
       
        let resultBook = SqlLibBook.queryChapterLessonByBookId(sqlLib, currentBookId)
        // console.log('resultBook',resultBook);
        if (sqlLib.checkSqlError(resultBook)) {
          if (resultBook !== null) {
            this.menuList.course = []
            resultBook.forEach((chapter) => {
              let tempLessonVO = []
              chapter.lessonVO.forEach((lesson) => {
                tempLessonVO.push({
                  name: lesson.name,
                  id: lesson.id,
                  isCharged: lesson.isCharged,
                  isUpdate: false,
                })
              })
              this.menuList.course.push({
                name: chapter.name,
                id: chapter.id,
                lessonVOList: tempLessonVO,
              })
            })
            if (this.menuList.course.length > 0) {
              this.menuList.currentLesson = this.menuList.course[0].lessonVOList[0].id
            }
          }
        } else {
            this.menuList.course = []
            let sqlLib = SqlLib.getInstance(window.$DBDIR)
            let user = SqlLibUser.queryCurrentUser(sqlLib)
            if (currentBookId !== user.id) {
                this.$message.warning('教材数据加载失败！')
            }
        }
      },
      initDownloadCenter() {
        let instance = DownloadCenter.getInstance(this)
        instance.request = resource
        instance.constVar = this.$CONST
        instance.downloadingSize = parseInt(this.$readIniFile('data', 'sameTimeDownloader'))
      },
      initDiyLessonItems(items){
        console.log('initDiyLessonItems',items);
        let _this = this
        let sqlLib = SqlLib.getInstance(window.$DBDIR)
        let user = SqlLibUser.queryCurrentUser(sqlLib)
        this.lessonInfo = items
        this.sqlParams = {
            userId: user.id,
            bookId: _this.menuList.bookId,
            lessonId: _this.menuList.currentLesson,
            lessonName: _this.lessonInfo.lessonName,
            isHomeDialogShow: _this.isHomeDialogShow,
        }
        _this.active = 1
        _this.isDiyLesson = true
        this.$refs.lessonRef.initLessonItem(items.lessonItems, _this.sqlParams)
       
      },
      initLessonItems(items,isCompleteEdit) {
        // console.log('initLessonItems-----------system',items);
        let _this = this
        this.isDiyLesson = false
        this.lessonInfo = items
        if (DownloadCenter.getInstance().lessonIsDownloading(this.menuList.currentLesson)) {
          //如果当前课程正在下载,重置下载遮罩的状态
          this.lessonInfo.homeDialog = true
          this.lessonInfo.shadeInfo.isDownloading = true
          this.lessonInfo.shadeInfo.downloadStatus = true
        }
        this.sqlParams = {
          userId: this.menuList.userId,
          bookId: this.menuList.bookId,
          lessonId: this.menuList.currentLesson,
          lessonName: this.lessonInfo.lessonName,
          isHomeDialogShow: this.isHomeDialogShow,
        }
        this.$refs.lessonRef.initLessonItem(items.lessonItems, this.sqlParams,isCompleteEdit)
        this.active = 1
        //课程加载完成之后，判断是否有版本更新弹框
        let sqlLib = SqlLib.getInstance(window.$DBDIR)
        let user = SqlLibUser.queryCurrentUser(sqlLib)
        if (user.schoolId) {
          //代表没有完善个人信息弹框
          if (localStorage.isProductUpdate) {
            let updateStr = JSON.parse(localStorage.isProductUpdate)
            UpdateApp.update(updateStr.exePath, updateStr.exeParmsArr, updateStr.message)
            localStorage.removeItem('isProductUpdate') //弹框一次即可
          } else {
            let versionUpdate = new VersionUpdater(resource)
            if (versionUpdate.isRequireRefresh()) {
              //如果需要刷新，就刷新
              this.$dialog({
                title: '提示',
                confirm: '确定',
                cancel: '取消',
                type: 'warn',
                close: false,
                message: '检测到已下载课本资源，需联网升级后方可使用！',
              })
                .then((value) => {
                  if (localStorage.isOffline === 'false') {
                    //在线才进行数据清洗
                    let options = {
                      title: '正在联网升级课本资源，请勿关闭并耐心等待',
                      time: 60 * 60 * 1000,
                    }
                    let loadingMask = this.$downloadmask('#lesson', options)
                    setTimeout(function () {
                      versionUpdate.refreshDB(
                        function () {
                          versionUpdate.removeOldBakup()

                          let maskProgress = new CustomEvent('maskProgress', {
                            detail: { progress: 100 },
                          })
                          window.dispatchEvent(maskProgress)
                          loadingMask.close()

                          this.showBeginnerGudiance()
                        },
                        function (progress) {
                          let maskProgress = new CustomEvent('maskProgress', {
                            detail: { progress: progress ? progress : 0 },
                          })
                          window.dispatchEvent(maskProgress)
                        }
                      )
                    }, 200)
                  } else {
                    _this.$message.warning('请连网升级!')
                    this.showBeginnerGudiance()
                  }
                })
                .catch(() => {
                  if (localStorage.isOffline === 'false') {
                    //在线取消才删除老数据
                    versionUpdate.removeOldBakup()
                  }
                  this.showBeginnerGudiance()
                })
            } else {
              this.showBeginnerGudiance()
            }
          }
        }
      },
      showBeginnerGudiance() {
        let sqlLib = SqlLib.getInstance(window.$DBDIR)
        let user = SqlLibUser.queryCurrentUser(sqlLib)
        if (user.reverse1) return
        userApi.getUserInfo().then(res=>{
          if (res.code === '0') {
            console.log(res);
            store.state.becomeVip = res.returnValue.isVip
          }
        })
        console.log(store);
        this.isShowBeginnerGudiance = true
      },
      saveAllbook(){//保存全书下载记录(删除全书功能)
        let _this = this
        var filename = []
        _this.menuList.course.forEach((item)=>{
          item.lessonVOList.forEach(index=>{
            resource.getResAndCouesewareByLessonId({
                lessonId:index.id
              }).then(res=>{
              if (res.code === '0') {
                console.log(res);
                if (!res.returnValue.resCoursewaresVOList && !res.returnValue.resourceVOList && !res.returnValue.tResPaperFileVOList){
                    console.log('这一课没有资源');
                    return
                }
                if (res.returnValue.resCoursewaresVOList) {
                    var resCoursewaresVOList = res.returnValue.resCoursewaresVOList
                    if (localStorage.resCoursewaresVOList) {
                        var oldresc = JSON.parse(localStorage.resCoursewaresVOList)
                        resCoursewaresVOList = oldresc.concat(resCoursewaresVOList)
                    }
                    localStorage.removeItem('resCoursewaresVOList')
                    localStorage.setItem('resCoursewaresVOList', JSON.stringify(resCoursewaresVOList))
                }
                if (res.returnValue.resourceVOList) {
                  var resourceVOList = res.returnValue.resourceVOList
                  if (localStorage.resourceVOList) {
                    var oldres = JSON.parse(localStorage.resourceVOList)
                    resourceVOList = oldres.concat(resourceVOList)
                  }
                  localStorage.removeItem('resourceVOList')
                  localStorage.setItem('resourceVOList', JSON.stringify(resourceVOList))
                }
               
                if (res.returnValue.tResPaperFileVOList) {
                  var tResPaperFileVOList = res.returnValue.tResPaperFileVOList
                  if (localStorage.tResPaperFileVOList) {
                    var oldtres = JSON.parse(localStorage.tResPaperFileVOList)
                    tResPaperFileVOList = oldtres.concat(tResPaperFileVOList) 
                  }
                  localStorage.removeItem('tResPaperFileVOList')
                  localStorage.setItem('tResPaperFileVOList', JSON.stringify(tResPaperFileVOList))
                }
              }
            })
          })
        })

        setTimeout(() => {
            console.log('记录----------------');
        
        if (localStorage.resCoursewaresVOList) {
          let resource = JSON.parse(localStorage.resCoursewaresVOList) 
            resource.forEach(v=>{
              if (v !== null && v.id) {
                filename.push(v.id)
              }
            })
        }
        if (localStorage.resourceVOList) {
          let resource = JSON.parse(localStorage.resourceVOList) 
            resource.forEach(v=>{
              if (v !== null) {
                filename.push(v.resMetaInfoVO.meta_id)
              }
            })
        }
        if (localStorage.tResPaperFileVOList) {
          let resource = JSON.parse(localStorage.tResPaperFileVOList) 
            resource.forEach(v=>{
              if (v !== null && v.id) {
                filename.push(v.id)
              }
            })
        }
        var downloadedFile = [{//构建记录此次下载的对象
          book:{
            bookName:_this.menuList.bookName,
            bookId:_this.menuList.bookId,
            fileName:filename
          },
        }]
        if (localStorage.downloadedFile){
          var downloadedOldFile  = JSON.parse(localStorage.downloadedFile)
          downloadedFile = downloadedOldFile.concat(downloadedFile)
        }
        console.log(downloadedFile);
        localStorage.removeItem('downloadedFile')
        localStorage.setItem('downloadedFile', JSON.stringify(downloadedFile))
        localStorage.removeItem('resCoursewaresVOList')
        localStorage.removeItem('resourceVOList')
        localStorage.removeItem('tResPaperFileVOList')
        console.log(JSON.parse(localStorage.downloadedFile));
          
        }, 3000);
      },
      //第一种是数据已经初始化好的
      /**
       * @param isPush 下载中心是否直接推入的标志
       */
      pushOneLessonToCenter(isPush) {
        let fn = null //用于推入的函数
        let _this = this
        let sqlLib = SqlLib.getInstance(window.$DBDIR)
        let tableNames = SqlLibBook.queryChaAndBookNameByLessonId(sqlLib, _this.menuList.currentLesson)
        console.log(_this.menuList);
        let downloadParam = {
          SetDownloadId: _this.menuList.currentLesson,
          DownloaderInfo: { lessonName: _this.lessonInfo.lessonName, bookName: tableNames.bookName, publisherName: tableNames.publisherName },
          DownloadParams: [],
          ActionStatus: '0', //动作的状态：0 - 下载；1 - 更新；2 - 同步
        }
        _this.lessonInfo.lessonItems.forEach((item) => {
          downloadParam.DownloadParams.push(item.downloadInfo)
        })
        console.log(downloadParam);
        let downloadParamJson = JSON.stringify(downloadParam)
        // var name = []
        // if (downloadParam) {
        //   downloadParam.DownloadParams.forEach(item=>{
        //     // console.log(item);
        //     name.push(item.FileName)
        //   })
        // }
        // console.log(name);
        // return
        // var downloadedFile = [{//构建记录此次下载的对象
        //   book:{
        //     bookName:downloadParam.DownloaderInfo.bookName,
        //     bookId:_this.menuList.bookId,
        //     publisherName:downloadParam.DownloaderInfo.publisherName,
        //     fileName:name
        //   },
        // }]
        // if (localStorage.downloadedFile) {//第一次成功下载后生效
        //   var same = false
        //   var downloadedOldFile  = JSON.parse(localStorage.downloadedFile)
        //   downloadedOldFile.forEach(item=>{
        //     //遍历存储的下载记录,如果此次下载课程的书本已经存在于本地，直接塞到相同的课本里
        //     if(downloadedFile[0].book.bookName === item.book.bookName && 
        //       downloadedFile[0].book.publisherName === item.book.publisherName &&
        //       downloadedFile[0].book.bookId === item.book.bookId) {
        //       console.log('找到了');
        //       item.book.fileName = item.book.fileName.concat(downloadedFile[0].book.fileName)
        //       same = true 
        //       downloadedFile = downloadedOldFile
        //     }
        //   })
        //   if (same === false) {//没找到就将原来的存储记录与此次下载合并
        //     downloadedFile = downloadedOldFile.concat(downloadedFile)
        //   }
        //   localStorage.removeItem('downloadedFile')
        //   console.log(downloadedFile);
        // }
        // localStorage.setItem('downloadedFile', JSON.stringify(downloadedFile))
        // return
        let currentDownIds = DownloadCenter.getInstance().getCurrentDownloadingLesson()
        console.log('currentDownIds', currentDownIds)
        let isExist = false
        currentDownIds.forEach((currentId) => {
          if (currentId === _this.menuList.currentLesson) {
            isExist = true
          }
        })
        if (isExist) {
        //   this.$message.warning('该课程已添加至下载中心')
          return
        } else {
          // console.log([downloadParam]);
          fn = DownloadCenter.getInstance().syncPushDownloadCenter([downloadParam], isPush)
        }
        let user = SqlLibUser.queryCurrentUser(sqlLib)
        let downloader = new Downloader()
        downloader.id = downloadParam.SetDownloadId
        downloader.isBook = '0'
        downloader.downloadParam = downloadParamJson
        downloader.downloaderStatus = '0'
        downloader.userId = user.id
        downloader.fillTime = moment().format('YYYY-MM-DD HH:mm:ss')
        SqlLib.getInstance(window.$DBDIR).updateOrInsertObjectById(downloader)
        return fn
      },
      changeDownloadStatus(val, lessonId) {
        if (lessonId) {
          if (this.menuList.currentLesson === lessonId) {
            this.lessonInfo.shadeInfo.downloadStatus = val
          }
        } else {
          console.log('changeDownloadStatus');
          this.lessonInfo.shadeInfo.downloadStatus = val
        }
      },
      cancelShadeStatus(lessonId) {
        if (lessonId && lessonId === this.menuList.currentLesson) {
          console.log(`%c${lessonId}`, 'color: green;')
          bus.$emit('cancelEdit')
          // this.lessonInfo.homeDialog = false;
          this.$refs.menus.getLessonItems(lessonId)
        }
      },
      updateLesson() {
        this.$refs.menus.resetDownload()
      },
      resetLesson() {
        let _this = this
        this.lessonInfo.homeDialog = true
        this.lessonInfo.shadeInfo.isDownloading = true
        this.lessonInfo.shadeInfo.downloadStatus = true
        let sqlLib = SqlLib.getInstance(window.$DBDIR)
        let tableNames = SqlLibBook.queryChaAndBookNameByLessonId(sqlLib, _this.menuList.currentLesson)

        let downloadParam = {
          SetDownloadId: _this.menuList.currentLesson,
          DownloaderInfo: { lessonName: _this.lessonInfo.lessonName, bookName: tableNames.bookName, publisherName: tableNames.publisherName },
          ActionStatus: '1', //动作的状态：0 - 下载；1 - 更新；2 - 同步
        }
        console.log(downloadParam)
        let currentDownIds = DownloadCenter.getInstance().getCurrentDownloadingLesson()
        let isExist = false
        currentDownIds.forEach((currentId) => {
          if (currentId === _this.menuList.currentLesson) {
            isExist = true
          }
        })
        if (isExist) {
          this.$message.warning('本课程已加入下载中心，请勿重复更新！')
          return false
        } else {
          DownloadCenter.getInstance().syncPushDownloadCenter([downloadParam])
        }
        return true
      },
      resetLessons(lessonIds) {
        let _this = this
        let isCurrent = false
        let sqlLib = SqlLib.getInstance(window.$DBDIR)
        let downloadParams = []
        let currentDownIds = DownloadCenter.getInstance().getCurrentDownloadingLesson()
        lessonIds.forEach((lessonId) => {
          if (!currentDownIds.includes(lessonId)) {
            if (lessonId === _this.menuList.currentLesson) {
              isCurrent = true
            }
            let tableNames = SqlLibBook.queryChaAndBookNameByLessonId(sqlLib, lessonId)
            let downloadParam = {
              SetDownloadId: lessonId,
              DownloaderInfo: { lessonName: tableNames.lessonName, bookName: tableNames.bookName, publisherName: tableNames.publisherName },
              ActionStatus: '1', //动作的状态：0 - 下载；1 - 更新；2 - 同步
            }
            downloadParams.push(downloadParam)
          }
        })
        if (isCurrent) {
          this.lessonInfo.homeDialog = true
          this.lessonInfo.shadeInfo.isDownloading = true
          this.lessonInfo.shadeInfo.downloadStatus = true
        }
        if (downloadParams.length > 0) {
          DownloadCenter.getInstance().syncPushDownloadCenter(downloadParams)
        }
        bus.$emit('closeShowUpdata')
        console.log('更新结束');
      },
      updateBookAuthorize(bookId) {
        let sqlLib = SqlLib.getInstance(window.$DBDIR)
        let res = SqlLibBook.updateBookAuthorization(sqlLib, bookId)
        this.lessonInfo.shadeInfo.isDownloading = true
      },
      collectOsMessage(id) {
        try {
            const os = require('os')
            const process = require('process')
            const { screen } = require('electron').remote
            //当前盘符
            let macId = getMAC().replace(/\:/g, '-').toUpperCase();
            if (!macId) {
                console.log('获取macId失败',macId);
                return
            }
            const currentDisk = process.cwd().substr(0, 2).toUpperCase()
            let operatingSystem = {
              userId: id,
              macId: macId,
              osVersion: os.type() + os.release(),
              osBits: process.env['ProgramFiles(x86)'] ? 'x64' : 'x86',
              osRates: screen.getPrimaryDisplay().size.width + '*' + screen.getPrimaryDisplay().size.height,
              otherJson: {
                totalMem: (os.totalmem() / 1024 / 1024 / 1024).toFixed(2) + 'G',
                freeMem: (os.freemem() / 1024 / 1024 / 1024).toFixed(2) + 'G',
                hostname: os.hostname(),
                cpuType: os.cpus()[0].model,
                processDisk: currentDisk,
              },
            }
            const diskinfo = require('diskinfo')
            //获得所有磁盘空间
            diskinfo.getDrives(function (err, aDrives) {
              //遍历所有磁盘信息
              for (let i = 0; i < aDrives.length; i++) {
                //只获取当前磁盘信息
                if (aDrives[i].mounted) {
                  if (aDrives[i].mounted.toUpperCase() === currentDisk) {
                    if (aDrives[i].blocks) {
                      if (typeof operatingSystem.otherJson === 'string') break
                      //总量
                      operatingSystem.otherJson.diskTotalSize = (aDrives[i].blocks / 1024 / 1024 / 1024).toFixed(0) + 'G'
                      //可用
                      operatingSystem.otherJson.distFreeSize = (aDrives[i].available / 1024 / 1024 / 1024).toFixed(0) + 'G'
                      operatingSystem.otherJson = JSON.stringify(operatingSystem.otherJson)
                      userApi.perfectUserOS(operatingSystem).catch((err) => {
                        console.log(err)
                      })
                    }
                  }
                }
              }
            })
        } catch (error) {
            console.log('collectOsMessage  error',error);
        }
        
      },
      resetInitPage() {
        // this.isInitPage = false
      },
    },
  }
</script>

<style lang="scss" scoped>
  #courseware {
    display: flex;
    height: 100%;
    // padding-top: 2.222vh;
    position: relative;
    justify-content: flex-end;

    .border {
        width: 100%;
        height: 10px;
        background-color: #cdd8e1;
        opacity: 0.3;
    }
    .leftTop{
        position: absolute;
        left: 0;
        top: 0;
        width: 3px;
        height: 3px;
        z-index: 99;
        // background: #A4D4FE;
        background: red;
    }
    .resource {
      position: relative;
      padding: 17px 30px 0 ;
      display: flex;
      flex-direction: column;
      width: calc(100vw - 280px);
      transition: all 0.4s ease-in-out;
      border-radius: 12px 0px 0px 0px;
      box-shadow: 0px -8px 8px 0px rgba(19,118,209,0.15);
      background: #fff;
      &-lessons {
        margin: 0 140px;
        border-radius: 12px 12px 0px 0px;
      }
      #coursewareContainer {
        flex: 1;
        height: calc(100% - 40px);
      }
      .top-title {
        position: relative;
        &-lessons {
        //   transform: translate(-20px);
        //   width: calc(100%);
        }
        .title {
          .lesson-name {
            display: inline-block;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-weight: bold;
            max-width: 20vw;
          }
          @media screen and (min-width: 1439px) {
            .lesson-name {
              max-width: 28vw;
            }
          }
          .lesson-logo {
            width: 24px;
            height: 25px;
            margin-right: 10px;
          }
        }
      }

      .switch {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        color: #0085ff;
        overflow: hidden;
        &-item {
        //   display: inline-block;
          white-space: nowrap;

          padding: 6px 15px;
          border: 1px solid #0085ff;
          &:nth-child(1) {
            border-radius: 4px 0px 0px 4px;
          }
          &:nth-child(2) {
            border-radius: 0 4px 4px 0;
          }
        }
        .border-b {
          width: 28px;
          height: 2px;
          background-color: transparent;
          margin-top: 0.486vw;
        }
        .isactive {
          color: #fff;
          background: #0085ff;
          // border: 1px solid #0085ff;
          // border: none;
        }
      }
      .update {
        width: 58px;
        height: 24px;
        line-height: 23px;
        border: 1px solid rgba(245, 108, 107, 1);
        border-radius: 0.833vw;
        color: #f56c6b;
        display: inline-block;
        text-align: center;
        margin-left: 10px;
        cursor: pointer;
      }
      .downloadAgain{
        width: auto;
        padding: 0 10px;
        height: 24px;
        line-height: 22px;
        font-size: 12px;
        border: 1px solid #0085ff;
        border-radius: 0.833vw;
        color: #0085ff;
        display: inline-block;
        text-align: center;
        cursor: pointer;
        margin-left: 10px;
        transition: all 0.5s;
      }
      .start {
        width: 88px;
        height: 32px;
        line-height: 32px;
        text-align: center;
        color: #fff;
        border-radius: 4px;
        border: none;
        outline: none;
        background-color: #dae1ea;
      }
      .start-back {
        background: linear-gradient(90deg, rgba(24, 207, 182, 1), rgba(30, 215, 186, 1));
        box-shadow: 0vw 0.208vw 0.417vw 0vw rgba(49, 198, 165, 0.3);
      }
      .class-status {
        img {
          width: 16px;
          height: 16px;
          margin-right: 5px;
          margin-top: 3px;
        }
      }
      .dis-btn {
        filter: grayscale(1);
        opacity: 0.7;
        cursor: no-drop;
      }
      .status {
        width: 88px;
        height: 32px;
        background: linear-gradient(270deg, #fcc200 0%, #ff9d29 100%);
        border-radius: 4px;
      }
    }
  }
</style>
